home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume5 / lwf / part01 next >
Encoding:
Internet Message Format  |  1989-02-03  |  57.9 KB

  1. Path: xanth!nic.MR.NET!hal!ncoast!allbery
  2. From: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
  3. Newsgroups: comp.sources.misc
  4. Subject: v05i001: lwf (print Japanese on LW), part 1 of 3
  5. Message-ID: <8810201304.AA10804@uhccux.uhcc.Hawaii.Edu>
  6. Date: 22 Oct 88 02:34:34 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
  9. Lines: 1948
  10. Approved: allbery@ncoast.UUCP
  11.  
  12. Posting-number: Volume 5, Issue 1
  13. Submitted-by: "Greg Lee " <lee@uhccux.uhcc.Hawaii.Edu>
  14. Archive-name: lwf/Part1
  15.  
  16. This is a modification of a program by Barry Brachman to translate ascii
  17. files to PostScript.  The first version appeared in comp.sources.unix in
  18. May.  This version prints Japanese, encoded in the JIS standard (two
  19. ascii characters per kanji).  You will need the font k14.snf from the X
  20. window system, V11, R2, to use it -- the font is not included here (it's
  21. too big).
  22.  
  23.         Greg Lee, lee@uhccux.uhcc.hawaii.edu
  24.  
  25. --------------------cut-----------------------
  26. #! /bin/sh
  27. # This is a shell archive.  Remove anything before this line, then unpack
  28. # it by saving it into a file and typing "sh file".  To overwrite existing
  29. # files, type "sh file -c".  You can also feed this as standard input via
  30. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  31. # will see the following message at the end:
  32. #        "End of archive 1 (of 3)."
  33. # Contents:  MANIFEST Makefile README Xmd.h Xprotostr.h fc.h font.h
  34. #   fontstruct.h kfont.c ktest lwf.man misc.h os.h range.c servermd.h
  35. # Wrapped by lee@uhccux on Wed Oct 19 17:12:32 1988
  36. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  37. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  39. else
  40. echo shar: Extracting \"'MANIFEST'\" \(672 characters\)
  41. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  42. X   File Name        Archive #    Description
  43. X-----------------------------------------------------------
  44. X MANIFEST                   1    This shipping list
  45. X Makefile                   1    
  46. X README                     1    
  47. X X.h                        2    
  48. X Xmd.h                      1    
  49. X Xproto.h                   3    
  50. X Xprotostr.h                1    
  51. X fc.h                       1    
  52. X font.h                     1    
  53. X fontstruct.h               1    
  54. X kfont.c                    1    
  55. X ktest                      1    
  56. X lwf.c                      2    
  57. X lwf.man                    1    
  58. X misc.h                     1    
  59. X os.h                       1    
  60. X range.c                    1    
  61. X servermd.h                 1    
  62. END_OF_FILE
  63. if test 672 -ne `wc -c <'MANIFEST'`; then
  64.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  65. fi
  66. # end of 'MANIFEST'
  67. fi
  68. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  69.   echo shar: Will not clobber existing file \"'Makefile'\"
  70. else
  71. echo shar: Extracting \"'Makefile'\" \(1459 characters\)
  72. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  73. X
  74. XCFLAGS = -O
  75. X
  76. X# Where to put lwf
  77. XLWF = /uh5h/ling/lee/bin/lwf
  78. X
  79. X# Where to put the man page
  80. XMAN = /uh5h/ling/lee/man/manl/lwf.1
  81. X
  82. X# Where to put the PostScript prologue file
  83. X#PROLOGUE = /uh5h/ling/lee/lib/lwf.prologue
  84. X#(prologue incorporated -- gl)
  85. X
  86. X# Environment options:
  87. X#
  88. X# -DPR=\"where pr is if not /bin/pr\"
  89. X# -DSYSV            For System V (assumes SYSV-style pr)
  90. X# -DREVERSE=0        Set to non-zero if page reversal is to be the default
  91. X# -DHOSTNAME=\"yourhostname\"    If you don't have the hostname() system call
  92. X# -DKPLACE=\"/usr/local/lib/k14.snf\"    Or wherever the kanji font is
  93. X# -DKANJI        To include the printing of kanji
  94. X#ENV = -DPROLOGUE=\"$(PROLOGUE)\" -DREVERSE=0
  95. XENV = -DREVERSE=0 -DKANJI -DKPLACE=\"k14.snf\"
  96. X
  97. XKFONT = kfont.o
  98. XXHEADERS = X.h Xmd.h Xproto.h Xprotostr.h fc.h font.h fontstruct.h \
  99. X misc.h os.h servermd.h
  100. X
  101. Xall:    lwf
  102. X
  103. Xlwf: lwf.o range.o $(KFONT)
  104. X    cc $(CLFAGS) -o lwf lwf.o range.o $(KFONT) -lm
  105. X
  106. Xlwf.o: lwf.c
  107. X    cc $(CFLAGS) -c $(ENV) lwf.c
  108. X
  109. Xrange.o: range.c
  110. X    cc $(CFLAGS) -c range.c
  111. X
  112. Xkfont.o: kfont.c $(XHEADERS)
  113. X    cc $(CFLAGS) -c kfont.c
  114. X
  115. X# Create the program to demonstrate and debug the range checking routine
  116. Xrange: range.c
  117. X    cc $(CFLAGS) -DRANGE_DEBUG -o range range.c
  118. X
  119. Xinstall: lwf lwf.man
  120. X#    cp prologue $(PROLOGUE)
  121. X#    chmod 0644 $(PROLOGUE)
  122. X    cp lwf $(LWF)
  123. X    chmod 0755 $(LWF)
  124. X    ls -l $(LWF)
  125. X    cp lwf.man $(MAN)
  126. X    rm -f lwf lwf.o range.o kfont.o
  127. X
  128. Xlint:
  129. X    lint -abchx $(ENV) lwf.c
  130. X
  131. Xclean:
  132. X    rm -f core lwf lwf.o range.o kfont.o
  133. X
  134. Xshar:
  135. X    makekit -nlwf. -m
  136. END_OF_FILE
  137. if test 1459 -ne `wc -c <'Makefile'`; then
  138.     echo shar: \"'Makefile'\" unpacked with wrong size!
  139. fi
  140. # end of 'Makefile'
  141. fi
  142. if test -f 'README' -a "${1}" != "-c" ; then 
  143.   echo shar: Will not clobber existing file \"'README'\"
  144. else
  145. echo shar: Extracting \"'README'\" \(2332 characters\)
  146. sed "s/^X//" >'README' <<'END_OF_FILE'
  147. X
  148. XLwf converts ASCII text files to PostScript.
  149. XIt has been tested on the Apple LaserWriter/LaserWriter+ and the NEC
  150. XSilentwriter LC-890.  Most of the processing is done on the host
  151. Xrather than on the printer.  The name "lwf", perhaps poorly chosen, stands
  152. Xfor "LaserWriter Filter".
  153. X
  154. XThere may be a couple of minor Berkeley-isms in the program (see the
  155. Xroutine setup()) and it is somewhat Unix dependent (eg., popen(), /bin/pr
  156. Xare expected).  The output conforms to the Adobe 2.0 file structuring
  157. Xconventions.  The program is set up to use the (fixed-width) Courier font.
  158. XIf you use another font you'll have to modify the mapping table in lwf.c.
  159. XI can't recommend a proportional font for this purpose.
  160. X
  161. XThe distribution includes the following files:
  162. X
  163. XREADME      This file
  164. XMakefile
  165. Xlwf.c       LaserWriter filter to convert ASCII text to PostScript
  166. Xrange.c     Routine to check if a number is in a given range
  167. Xlwf.man     Manual page for lwf
  168. Xprologue    Default PostScript support file
  169. X
  170. XPlease check the Makefile and the configurable #defines in lwf.c.
  171. XCheck if the man page needs to be revised for your environment.
  172. XYou can then proceed with 'make install'.
  173. X
  174. XIf you come across any bugs, including nonconformance to Adobe 2.0, or
  175. Xmake any changes you'd like to share please send mail to me rather than
  176. Xposting to the net.
  177. X
  178. XEnjoy.
  179. X
  180. X-----
  181. XBarry Brachman           | {ihnp4!alberta,uw-beaver,uunet}!
  182. XDept. of Computer Science|  ubc-vision!ubc-csgrads!brachman
  183. XUniv. of British Columbia| brachman@grads.cs.ubc.cdn
  184. XVancouver, B.C. V6T 1W5  | brachman%ubc.csnet@csnet-relay.arpa
  185. X(604) 228-4327           | brachman@ubc.csnet
  186. X
  187. X-----
  188. X
  189. XChanges by Greg Lee, 10/88:
  190. X
  191. X(1) I eliminated the prologue file by printing out the contents
  192. Xdirectly in lwf.c (don't like unnecessary library files hanging
  193. Xaround).  Added supported point sizes 14, 16, 18.
  194. X
  195. X(2) Added support for printing Japanese language text.
  196. X
  197. X(3) Additional files:
  198. X
  199. Xkfont.c        routines for accessing kanji font k14.snf
  200. X        (adapted from the X11, R2 font compiler, by Ralph Swick)
  201. Xk14.snf (not included)
  202. X        kanji font for kterm, from X11, R2
  203. Xktest        sample file with Japanese text (= a posting in gnu.emacs.gnus)
  204. XX.h        various .h files from the X11, R2 distribution
  205. XXmd.h
  206. XXproto.h
  207. XXprotostr.h
  208. Xfc.h
  209. Xfont.h
  210. Xfontstruct.h
  211. Xmisc.h
  212. Xos.h
  213. Xservermd.h
  214. X
  215. X------
  216. XGreg Lee, lee@uhccux.uhcc.hawaii.edu
  217. X------
  218. END_OF_FILE
  219. if test 2332 -ne `wc -c <'README'`; then
  220.     echo shar: \"'README'\" unpacked with wrong size!
  221. fi
  222. # end of 'README'
  223. fi
  224. if test -f 'Xmd.h' -a "${1}" != "-c" ; then 
  225.   echo shar: Will not clobber existing file \"'Xmd.h'\"
  226. else
  227. echo shar: Extracting \"'Xmd.h'\" \(1967 characters\)
  228. sed "s/^X//" >'Xmd.h' <<'END_OF_FILE'
  229. X/***********************************************************
  230. XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  231. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  232. X
  233. X                        All Rights Reserved
  234. X
  235. XPermission to use, copy, modify, and distribute this software and its 
  236. Xdocumentation for any purpose and without fee is hereby granted, 
  237. Xprovided that the above copyright notice appear in all copies and that
  238. Xboth that copyright notice and this permission notice appear in 
  239. Xsupporting documentation, and that the names of Digital or MIT not be
  240. Xused in advertising or publicity pertaining to distribution of the
  241. Xsoftware without specific, written prior permission.  
  242. X
  243. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  244. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  245. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  246. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  247. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  248. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  249. XSOFTWARE.
  250. X
  251. X******************************************************************/
  252. X#ifndef XMD_H
  253. X#define XMD_H 1
  254. X/* $Header: Xmd.h,v 1.22 87/09/07 18:07:40 toddb Exp $ */
  255. X/*
  256. X *  Xmd.h: MACHINE DEPENDENT DECLARATIONS.
  257. X */
  258. X
  259. X/*
  260. X * ibm pcc doesn't understand pragmas.
  261. X */
  262. X#if defined(ibm032) && !defined(_pcc_)
  263. Xpragma on(pointers_compatible);
  264. Xpragma off(char_default_unsigned);
  265. X#endif
  266. X
  267. X/*
  268. X * Bitfield suffixes for the protocol structure elements, if you
  269. X * need them.
  270. X */
  271. X#define B16
  272. X#define B32
  273. X
  274. Xtypedef long           INT32;
  275. Xtypedef short          INT16;
  276. Xtypedef char           INT8;
  277. X
  278. Xtypedef unsigned long CARD32;
  279. Xtypedef unsigned short CARD16;
  280. Xtypedef unsigned char  CARD8;
  281. X
  282. Xtypedef unsigned long        BITS32;
  283. Xtypedef unsigned short        BITS16;
  284. Xtypedef unsigned char        BYTE;
  285. X
  286. Xtypedef unsigned char            BOOL;
  287. X
  288. X#endif /* XMD_H */
  289. END_OF_FILE
  290. if test 1967 -ne `wc -c <'Xmd.h'`; then
  291.     echo shar: \"'Xmd.h'\" unpacked with wrong size!
  292. fi
  293. # end of 'Xmd.h'
  294. fi
  295. if test -f 'Xprotostr.h' -a "${1}" != "-c" ; then 
  296.   echo shar: Will not clobber existing file \"'Xprotostr.h'\"
  297. else
  298. echo shar: Extracting \"'Xprotostr.h'\" \(1804 characters\)
  299. sed "s/^X//" >'Xprotostr.h' <<'END_OF_FILE'
  300. X/* $Header: Xprotostr.h,v 1.2 88/01/30 17:49:46 rws Exp $ */
  301. X#ifndef XPROTOSTRUCTS_H
  302. X#define XPROTOSTRUCTS_H
  303. X
  304. X/***********************************************************
  305. XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  306. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  307. X
  308. X                        All Rights Reserved
  309. X
  310. XPermission to use, copy, modify, and distribute this software and its 
  311. Xdocumentation for any purpose and without fee is hereby granted, 
  312. Xprovided that the above copyright notice appear in all copies and that
  313. Xboth that copyright notice and this permission notice appear in 
  314. Xsupporting documentation, and that the names of Digital or MIT not be
  315. Xused in advertising or publicity pertaining to distribution of the
  316. Xsoftware without specific, written prior permission.  
  317. X
  318. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  319. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  320. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  321. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  322. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  323. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  324. XSOFTWARE.
  325. X
  326. X******************************************************************/
  327. X#include "Xmd.h"
  328. X
  329. X/* Used by PolySegment */
  330. X
  331. Xtypedef struct _xSegment {
  332. X    INT16 x1 B16, y1 B16, x2 B16, y2 B16;
  333. X} xSegment;
  334. X
  335. X/* POINT */
  336. X
  337. Xtypedef struct _xPoint {
  338. X    INT16        x B16, y B16;
  339. X} xPoint;
  340. X
  341. Xtypedef struct _xRectangle {
  342. X    INT16 x B16, y B16;
  343. X    CARD16  width B16, height B16;
  344. X} xRectangle;
  345. X
  346. X/*  ARC  */
  347. X
  348. Xtypedef struct _xArc {
  349. X    INT16 x B16, y B16;
  350. X    CARD16   width B16, height B16;
  351. X    INT16   angle1 B16, angle2 B16;
  352. X} xArc;
  353. X
  354. X#endif /* XPROTOSTRUCTS_H */
  355. END_OF_FILE
  356. if test 1804 -ne `wc -c <'Xprotostr.h'`; then
  357.     echo shar: \"'Xprotostr.h'\" unpacked with wrong size!
  358. fi
  359. # end of 'Xprotostr.h'
  360. fi
  361. if test -f 'fc.h' -a "${1}" != "-c" ; then 
  362.   echo shar: Will not clobber existing file \"'fc.h'\"
  363. else
  364. echo shar: Extracting \"'fc.h'\" \(2107 characters\)
  365. sed "s/^X//" >'fc.h' <<'END_OF_FILE'
  366. X#ifdef SYSV
  367. X#include <memory.h>
  368. X#define bzero(b,length) memset(b,0,length)
  369. X/* these are not strictly equivalent, but suffice for uses here */
  370. X#define bcopy(b1,b2,length) memcpy(b2,b1,length)
  371. X#endif /* SYSV */
  372. X
  373. X#define MIN(a,b) ((a)>(b)?(b):(a))
  374. X#define MAX(a,b) ((a)>(b)?(a):(b))
  375. X
  376. Xtypedef struct _GlyphMap {
  377. X    char    *bits;
  378. X    int        h;
  379. X    int        w;
  380. X    int        widthBytes;
  381. X} GlyphMap;
  382. X
  383. X/*
  384. X * a structure to hold all the pointers to make it easy to pass them all
  385. X * around. Much like the FONT structure in the server.
  386. X */
  387. X
  388. Xtypedef struct _TempFont {
  389. X    FontInfoPtr pFI;
  390. X    CharInfoPtr pCI;
  391. X    unsigned char *pGlyphs;
  392. X    FontPropPtr pFP;
  393. X} TempFont; /* not called font since collides with type in X.h */
  394. X
  395. X#ifdef vax
  396. X
  397. X#    define DEFAULTGLPAD     1        /* default padding for glyphs */
  398. X#    define DEFAULTBITORDER     LSBFirst    /* default bitmap bit order */
  399. X
  400. X#else
  401. X# ifdef sun
  402. X
  403. X#  if (sun386 || sun5)
  404. X#    define DEFAULTGLPAD     4        /* default padding for glyphs */
  405. X#    define DEFAULTBITORDER     LSBFirst    /* default bitmap bit order */
  406. X#  else
  407. X#    define DEFAULTGLPAD     4        /* default padding for glyphs */
  408. X#    define DEFAULTBITORDER     MSBFirst    /* default bitmap bit order */
  409. X#  endif
  410. X
  411. X# else
  412. X#  ifdef apollo
  413. X
  414. X#    define DEFAULTGLPAD     2        /* default padding for glyphs */
  415. X#    define DEFAULTBITORDER     MSBFirst    /* default bitmap bit order */
  416. X
  417. X#  else
  418. X#   ifdef ibm032
  419. X
  420. X#    define DEFAULTGLPAD     1        /* default padding for glyphs */
  421. X#    define DEFAULTBITORDER     MSBFirst    /* default bitmap bit order */
  422. X
  423. X#   else
  424. X#    ifdef hpux
  425. X
  426. X#    define DEFAULTGLPAD     2        /* default padding for glyphs */
  427. X#    define DEFAULTBITORDER     MSBFirst    /* default bitmap bit order */
  428. X
  429. X#    else
  430. X#     define DEFAULTGLPAD     1        /* default padding for glyphs */
  431. X#     define DEFAULTBITORDER MSBFirst    /* default bitmap bit order */
  432. X#        define UNSPECIFIED
  433. X
  434. X#    endif
  435. X#   endif
  436. X#  endif
  437. X# endif
  438. X#endif
  439. X
  440. X#define GLWIDTHBYTESPADDED(bits,nbytes) \
  441. X    ((nbytes) == 1 ? (((bits)+7)>>3)    /* pad to 1 byte */ \
  442. X    :(nbytes) == 2 ? ((((bits)+15)>>3)&~1)    /* pad to 2 bytes */ \
  443. X    :(nbytes) == 4 ? ((((bits)+31)>>3)&~3)    /* pad to 4 bytes */ \
  444. X    :(nbytes) == 8 ? ((((bits)+63)>>3)&~7)    /* pad to 8 bytes */ \
  445. X    : 0)
  446. X
  447. END_OF_FILE
  448. if test 2107 -ne `wc -c <'fc.h'`; then
  449.     echo shar: \"'fc.h'\" unpacked with wrong size!
  450. fi
  451. # end of 'fc.h'
  452. fi
  453. if test -f 'font.h' -a "${1}" != "-c" ; then 
  454.   echo shar: Will not clobber existing file \"'font.h'\"
  455. else
  456. echo shar: Extracting \"'font.h'\" \(3869 characters\)
  457. sed "s/^X//" >'font.h' <<'END_OF_FILE'
  458. X/***********************************************************
  459. XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  460. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  461. X
  462. X                        All Rights Reserved
  463. X
  464. XPermission to use, copy, modify, and distribute this software and its 
  465. Xdocumentation for any purpose and without fee is hereby granted, 
  466. Xprovided that the above copyright notice appear in all copies and that
  467. Xboth that copyright notice and this permission notice appear in 
  468. Xsupporting documentation, and that the names of Digital or MIT not be
  469. Xused in advertising or publicity pertaining to distribution of the
  470. Xsoftware without specific, written prior permission.  
  471. X
  472. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  473. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  474. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  475. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  476. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  477. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  478. XSOFTWARE.
  479. X
  480. X******************************************************************/
  481. X#ifndef FONT_H
  482. X#define FONT_H 1
  483. X#define FONT_FILE_VERSION    4
  484. X
  485. X#include "servermd.h"
  486. X
  487. X#define NullCharInfo ((CharInfoPtr)0)
  488. X#define NullFontInfo ((FontInfoPtr)0)
  489. X#define LeftToRight 0
  490. X#define RightToLeft 1
  491. X#define BottomToTop 2
  492. X#define TopToBottom 3
  493. X/*
  494. X * for linear char sets
  495. X */
  496. X#define n1dChars(pfi) ((pfi)->lastCol - (pfi)->firstCol + 1)
  497. X#define chFirst firstCol    /* usage:  pfi->chFirst */
  498. X#define chLast lastCol        /* usage:  pfi->chLast */
  499. X
  500. X/*
  501. X * for 2D char sets
  502. X */
  503. X#define n2dChars(pfi)    (((pfi)->lastCol - (pfi)->firstCol + 1) * \
  504. X             ((pfi)->lastRow - (pfi)->firstRow + 1))
  505. X
  506. X/*
  507. X * Some macros that font converters and font i/o routines will need.
  508. X */
  509. X
  510. X#define    GLWIDTHPIXELS(pci) \
  511. X    ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
  512. X#define    GLHEIGHTPIXELS(pci) \
  513. X     ((pci)->metrics.ascent + (pci)->metrics.descent)
  514. X
  515. X
  516. X/*
  517. X * the following macro definitions describe a font file image in memory
  518. X */
  519. X#define ADDRCharInfoRec( pfi)    \
  520. X    ((CharInfoRec *) &(pfi)[1])
  521. X
  522. X#define ADDRCHARGLYPHS( pfi)    \
  523. X    (((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi))
  524. X#define ADDRXTHISCHARINFO( pf, ch ) \
  525. X        ((CharInfoRec *) &((pf)->pCI[(ch) - (pf)->pFI->chFirst]))
  526. X
  527. X
  528. X/*
  529. X * pad out glyphs to a CARD32 boundary
  530. X */
  531. X#define ADDRXFONTPROPS( pfi)  \
  532. X    ((DIXFontProp *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi)))
  533. X
  534. X#define ADDRSTRINGTAB( pfi)  \
  535. X    ((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi))
  536. X
  537. X#define    BYTESOFFONTINFO(pfi)    (sizeof(FontInfoRec))
  538. X#define BYTESOFCHARINFO(pfi)    (sizeof(CharInfoRec) * n2dChars(pfi))
  539. X#define    BYTESOFPROPINFO(pfi)    (sizeof(FontPropRec) * (pfi)->nProps)
  540. X#define    BYTESOFSTRINGINFO(pfi)    ((pfi)->lenStrings)
  541. X#define    BYTESOFGLYPHINFO(pfi)    (((pfi)->maxbounds.byteOffset+3) & ~0x3)
  542. X#define    GLYPHWIDTHBYTES(pci)    (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
  543. X#define    GLYPHHEIGHTPIXELS(pci)    (pci->metrics.ascent + pci->metrics.descent)
  544. X#define    GLYPHWIDTHPIXELS(pci)    (pci->metrics.rightSideBearing \
  545. X                    - pci->metrics.leftSideBearing)
  546. X#define GLWIDTHPADDED( bc)    ((bc+7) & ~0x7)
  547. X
  548. X#if GLYPHPADBYTES == 0 || GLYPHPADBYTES == 1
  549. X#define    GLYPHWIDTHBYTESPADDED(pci)    (GLYPHWIDTHBYTES(pci))
  550. X#endif
  551. X
  552. X#if GLYPHPADBYTES == 2
  553. X#define    GLYPHWIDTHBYTESPADDED(pci)    ((GLYPHWIDTHBYTES(pci)+1) & ~0x1)
  554. X#endif
  555. X
  556. X#if GLYPHPADBYTES == 4
  557. X#define    GLYPHWIDTHBYTESPADDED(pci)    ((GLYPHWIDTHBYTES(pci)+3) & ~0x3)
  558. X#endif
  559. X
  560. X#if GLYPHPADBYTES == 8 /* for a cray? */
  561. X#define    GLYPHWIDTHBYTESPADDED(pci)    ((GLYPHWIDTHBYTES(pci)+7) & ~0x7)
  562. X#endif
  563. X
  564. Xtypedef struct _FontProp *FontPropPtr;
  565. Xtypedef struct _CharInfo *CharInfoPtr;
  566. Xtypedef struct _FontInfo *FontInfoPtr;
  567. Xtypedef unsigned int DrawDirection;
  568. Xtypedef struct _ExtentInfo *ExtentInfoPtr;
  569. X
  570. X
  571. X#endif /* FONT_H */
  572. END_OF_FILE
  573. if test 3869 -ne `wc -c <'font.h'`; then
  574.     echo shar: \"'font.h'\" unpacked with wrong size!
  575. fi
  576. # end of 'font.h'
  577. fi
  578. if test -f 'fontstruct.h' -a "${1}" != "-c" ; then 
  579.   echo shar: Will not clobber existing file \"'fontstruct.h'\"
  580. else
  581. echo shar: Extracting \"'fontstruct.h'\" \(4760 characters\)
  582. sed "s/^X//" >'fontstruct.h' <<'END_OF_FILE'
  583. X/***********************************************************
  584. XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  585. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  586. X
  587. X                        All Rights Reserved
  588. X
  589. XPermission to use, copy, modify, and distribute this software and its 
  590. Xdocumentation for any purpose and without fee is hereby granted, 
  591. Xprovided that the above copyright notice appear in all copies and that
  592. Xboth that copyright notice and this permission notice appear in 
  593. Xsupporting documentation, and that the names of Digital or MIT not be
  594. Xused in advertising or publicity pertaining to distribution of the
  595. Xsoftware without specific, written prior permission.  
  596. X
  597. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  598. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  599. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  600. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  601. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  602. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  603. XSOFTWARE.
  604. X
  605. X******************************************************************/
  606. X#ifndef FONTSTRUCT_H
  607. X#define FONTSTRUCT_H 1
  608. X#include "font.h"
  609. X#include "misc.h"
  610. X
  611. X/*
  612. X * This file describes the Server Natural Font format.
  613. X * SNF fonts are both CPU-dependent and frame buffer bit order dependent.
  614. X * This file is used by:
  615. X *    1)  the server, to hold font information read out of font files.
  616. X *    2)  font converters
  617. X *
  618. X * Each font file contains the following
  619. X * data structures, with no padding in-between.
  620. X *
  621. X *    1)  The XFONTINFO structure
  622. X *        hand-padded to a two-short boundary.
  623. X *
  624. X *    2)  The XCHARINFO array
  625. X *        indexed directly with character codes, both on disk
  626. X *        and in memory.
  627. X *
  628. X *    3)  Character glyphs
  629. X *        padded in the server-natural way, and
  630. X *        ordered in the device-natural way.
  631. X *        End of glyphs padded to 32-bit boundary.
  632. X *
  633. X *    4)  nProps font properties
  634. X *
  635. X *    5)  a sequence of null-terminated strings, for font properties
  636. X */
  637. X
  638. X
  639. Xtypedef struct _FontProp { 
  640. X    CARD32    name;        /* offset of string */
  641. X    INT32    value;        /* number or offset of string */
  642. X    Bool    indirect;    /* value is a string offset */
  643. X} FontPropRec;
  644. X
  645. Xtypedef struct _CharInfo {
  646. X    xCharInfo    metrics;    /* info preformatted for Queries */
  647. X    unsigned    byteOffset:24;    /* byte offset of the raster from pGlyphs */
  648. X    Bool    exists:1;    /* true iff glyph exists for this char */
  649. X    unsigned    pad:7;        /* must be zero for now */
  650. X} CharInfoRec;
  651. X
  652. X/*
  653. X * maxbounds.byteOffset is the total number of bytes in the glyph array,
  654. X * and maxbounds.bitOffset is total width of the unpadded font.
  655. X */
  656. Xtypedef struct _FontInfo {
  657. X    unsigned int    version1;   /* version stamp */
  658. X    unsigned int    allExist;
  659. X    unsigned int    drawDirection;
  660. X    unsigned int    noOverlap;    /* true if:
  661. X                     * max(rightSideBearing-characterWidth)
  662. X                     * <= minbounds->metrics.leftSideBearing
  663. X                     */
  664. X    unsigned int    constantMetrics;
  665. X    unsigned int    terminalFont;    /* Should be deprecated!  true if:
  666. X                       constant metrics &&
  667. X                       leftSideBearing == 0 &&
  668. X                       rightSideBearing == characterWidth &&
  669. X                       ascent == fontAscent &&
  670. X                       descent == fontDescent
  671. X                    */
  672. X    unsigned int    linear:1;    /* true if firstRow == lastRow */
  673. X    unsigned int    constantWidth:1;  /* true if minbounds->metrics.characterWidth
  674. X                       *      == maxbounds->metrics.characterWidth
  675. X                       */
  676. X    unsigned int    inkInside:1;    /* true if for all defined glyphs:
  677. X                     * leftSideBearing >= 0 &&
  678. X                     * rightSideBearing <= characterWidth &&
  679. X                     * -fontDescent <= ascent <= fontAscent &&
  680. X                     * -fontAscent <= descent <= fontDescent
  681. X                     */
  682. X    unsigned int    padding:29;
  683. X    unsigned int    firstCol;
  684. X    unsigned int    lastCol;
  685. X    unsigned int    firstRow;
  686. X    unsigned int    lastRow;
  687. X    unsigned int    nProps;
  688. X    unsigned int    lenStrings; /* length in bytes of string table */
  689. X    unsigned int    chDefault;  /* default character */ 
  690. X    unsigned int    fontDescent; /* minimum for quality typography */
  691. X    unsigned int    fontAscent;  /* minimum for quality typography */
  692. X    CharInfoRec        minbounds;  /* MIN of glyph metrics over all chars */
  693. X    CharInfoRec        maxbounds;  /* MAX of glyph metrics over all chars */
  694. X    unsigned int    pixDepth;   /* intensity bits per pixel */
  695. X    unsigned int    glyphSets;  /* number of sets of glyphs, for
  696. X                        sub-pixel positioning */
  697. X    unsigned int    version2;   /* version stamp double-check */
  698. X} FontInfoRec;
  699. X
  700. Xtypedef struct _ExtentInfo {
  701. X    DrawDirection    drawDirection;
  702. X    int            fontAscent;
  703. X    int            fontDescent;
  704. X    int            overallAscent;
  705. X    int            overallDescent;
  706. X    int            overallWidth;
  707. X    int            overallLeft;
  708. X    int            overallRight;
  709. X} ExtentInfoRec;
  710. X
  711. X#endif /* FONTSTRUCT_H */
  712. X
  713. END_OF_FILE
  714. if test 4760 -ne `wc -c <'fontstruct.h'`; then
  715.     echo shar: \"'fontstruct.h'\" unpacked with wrong size!
  716. fi
  717. # end of 'fontstruct.h'
  718. fi
  719. if test -f 'kfont.c' -a "${1}" != "-c" ; then 
  720.   echo shar: Will not clobber existing file \"'kfont.c'\"
  721. else
  722. echo shar: Extracting \"'kfont.c'\" \(2702 characters\)
  723. sed "s/^X//" >'kfont.c' <<'END_OF_FILE'
  724. X/* 
  725. X * $Locker:  $ 
  726. X */ 
  727. Xstatic char    *rcsid = "$Header: showsnf.c,v 1.4 87/12/17 13:12:46 rws Exp $";
  728. X#include <stdio.h>
  729. X#include <sys/types.h> 
  730. X#include <sys/file.h> 
  731. X#ifdef SYSV
  732. X#include <fcntl.h>
  733. X#endif /* SYSV */
  734. X#include <sys/stat.h> 
  735. X#include <errno.h> 
  736. X
  737. X#include "misc.h"
  738. X#include "Xmd.h"
  739. X#include "X.h"
  740. X#include "Xproto.h"
  741. X#include "fontstruct.h"
  742. X#include "font.h"
  743. X
  744. X#include "fc.h"
  745. X
  746. X#ifndef u_char
  747. X#define u_char    unsigned char
  748. X#endif
  749. X
  750. Xchar *    malloc();
  751. X
  752. Xint glyphPad = DEFAULTGLPAD;
  753. Xint bitorder = DEFAULTBITORDER;
  754. X
  755. XTempFont    tf;
  756. Xchar        *kbuf;
  757. X
  758. Xint openkfont(file)
  759. X    char    *file;
  760. X{
  761. X    struct stat    st;
  762. X    FontInfoRec f;
  763. X    int    fd, i, strings;
  764. X
  765. X    if (stat(file, &st) < 0) {
  766. X        fprintf(stderr, "can't stat %s\n", file);
  767. X        return(0);
  768. X    }
  769. X
  770. X    fd = open(file, O_RDONLY);
  771. X    if (fd < 0) {
  772. X        fprintf(stderr, "can't open %s\n", file);
  773. X        return(0);
  774. X    }
  775. X    kbuf = malloc(st.st_size);
  776. X    read(fd, kbuf, st.st_size);
  777. X    close(fd);
  778. X    tf.pFI = (FontInfoPtr)kbuf;
  779. X    tf.pCI = (CharInfoPtr)(kbuf + BYTESOFFONTINFO(tf.pFI));
  780. X    tf.pGlyphs = ((unsigned char *)tf.pCI) + BYTESOFCHARINFO(tf.pFI);
  781. X    tf.pFP = (FontPropPtr)(tf.pGlyphs + BYTESOFGLYPHINFO(tf.pFI));
  782. X    strings = (int)tf.pFP + BYTESOFPROPINFO(tf.pFI);
  783. X
  784. X    for (i=0; i<tf.pFI->nProps; i++) {
  785. X        tf.pFP[i].name += strings;
  786. X        if (tf.pFP[i].indirect)
  787. X            tf.pFP[i].value += strings;
  788. X    }
  789. X    return(1);
  790. X}
  791. X
  792. Xclosekfont()
  793. X{
  794. X    free(kbuf);
  795. X}
  796. X
  797. Xchar hexstring[80];
  798. X
  799. Xchar *kimage(crow, ccol)
  800. X    int     crow, ccol;
  801. X{
  802. X    hexstring[0] = 0;
  803. X    DumpBitmaps(&tf, crow, ccol);
  804. X    return(hexstring);
  805. X}
  806. X
  807. XDumpBitmaps(pFont, crow, ccol)
  808. X    TempFont *pFont;
  809. X    int        crow, ccol;
  810. X{
  811. X    int            ch;    /* current character */
  812. X    int            r;    /* current row */
  813. X    int            b;    /* current bit in the row */
  814. X    FontInfoPtr        pFI = pFont->pFI;
  815. X    CharInfoPtr        pCI = pFont->pCI;
  816. X    u_char *        bitmap = (u_char *)pFont->pGlyphs;
  817. X    int            bpr;
  818. X
  819. X    ch = (crow - pFont->pFI->firstRow)
  820. X     * (pFont->pFI->lastCol - pFont->pFI->firstCol + 1)
  821. X     + ccol - pFont->pFI->firstCol;
  822. X
  823. X    bpr = GLWIDTHBYTESPADDED(pCI[ch].metrics.rightSideBearing
  824. X        - pCI[ch].metrics.leftSideBearing, glyphPad);
  825. X
  826. X        if ( !pCI[ch].exists || pCI[ch].metrics.characterWidth == 0)
  827. X            return;
  828. X
  829. X        for (r=0; r <  pCI[ch].metrics.descent + pCI[ch].metrics.ascent; r++)
  830. X        {
  831. X        unsigned char *row = bitmap + pCI[ch].byteOffset+(r*bpr);
  832. X            for ( b=0;
  833. X        b < pCI[ch].metrics.rightSideBearing - pCI[ch].metrics.leftSideBearing;
  834. X        b += 4) {
  835. X        if (bitorder == LSBFirst) {
  836. X            addxchar( (b&4)? (row[b>>3] & 0xf0)>>4
  837. X                     :   (row[b>>3] & 0x0f) );
  838. X        } else {
  839. X            addxchar( (b&4)? (row[b>>3] & 0x0f)
  840. X                     :   (row[b>>3] & 0xf0)>>4 );
  841. X        }
  842. X        }
  843. X        }
  844. X}
  845. X
  846. Xaddxchar(nib)
  847. Xint nib;
  848. X{    char xs[3];
  849. X
  850. X    sprintf(xs, "%1x", nib);
  851. X    strcat(hexstring, xs);
  852. X}
  853. END_OF_FILE
  854. if test 2702 -ne `wc -c <'kfont.c'`; then
  855.     echo shar: \"'kfont.c'\" unpacked with wrong size!
  856. fi
  857. # end of 'kfont.c'
  858. fi
  859. if test -f 'ktest' -a "${1}" != "-c" ; then 
  860.   echo shar: Will not clobber existing file \"'ktest'\"
  861. else
  862. echo shar: Extracting \"'ktest'\" \(1506 characters\)
  863. sed "s/^X//" >'ktest' <<'END_OF_FILE'
  864. XPath: uhccux!humu!nosc!helios.ee.lbl.gov!lll-tis!lll-winken!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!kddlab!photon.stars.flab.fujitsu.junet!umerin
  865. XFrom: kddlab!photon.stars.flab.fujitsu.junet!umerin@UUNET.UU.NET (Masanobu UMEDA)
  866. XNewsgroups: gnu.emacs.gnus
  867. XSubject: GNUS -> mh-e
  868. XMessage-ID: <8809220642.AA00918@photon.stars.flab.fujitsu.junet>
  869. XDate: 22 Sep 88 06:42:22 GMT
  870. XReferences: <8809220425.AA00812@rei.stars.flab.fujitsu.junet>
  871. XSender: daemon@tut.cis.ohio-state.edu
  872. XDistribution: gnu
  873. XOrganization: The Internet
  874. XLines: 27
  875. X
  876. X
  877. X   Date: Thu, 22 Sep 88 13:25:11 +0900
  878. X   From: yuki@rei.stars.flab.fujitsu.junet
  879. X
  880. X   $@$^$:!$(Jmh-e $@$r;H$$$?$$$H$$$&$N$OMW$9$k$K$I$&$$$&5!G=$,$&$l$7$$$N$+$H$$(J
  881. X   $@$&$H(J
  882. X   (1) $@%*%j%8%J%k$KBP$7$F(J replcomps $@$H(J mhl.reply $@$,F/$$$F9%$_$N%X%C%@$,<+(J
  883. X       $@F0E*$K$G$-$k!%(J
  884. X   (2) C-c C-y $@$G%*%j%8%J%k$rFI$_9~$a$k(J.
  885. X   (3) C-c C-s $@$G(J signature $@$,FI$_9~$a$k(J.
  886. X   (4) draftfolder $@$r;H$C$F$$$k>l9g$K$OJ#?t$N(J draft $@$+$-$+$1$GCfCG$7$F$*(J
  887. X       $@$1$k!%(J 
  888. X   (5) Fcc $@$G95$($,%U%)%k%@$K$H$l$k!%(J
  889. X   (6) alias $@5!G=$,;H$($k(J
  890. X
  891. XRMAIL $@$G4JC1$K$G$-$J$$$3$H$O(J (1) $@$@$1$G$9(J. 
  892. X
  893. X    (2) $@$b$A$m$s$G$-$^$9(J. 
  894. X    (3)  C-c C-w $@$G$G$-$^$9(J.
  895. X    (4) $@%P%C%U%!L>$rJQ99$9$l$P$G$-$^$9(J. 
  896. X    (5) (setq mail-archive-file-name "$@%U%!%$%kL>(J") $@$G(J 
  897. X        $@F1$8$h$&$K(J Fcc: $@$GJ]B8$9$k$3$H$,$G$-$^$9(J.
  898. X        $@$?$@$7(J Unix mail format.
  899. X    (6) $@$b$A$m$s$G$-$^$9(J.
  900. X
  901. XMasanobu UMEDA
  902. Xumerin@flab.flab.Fujitsu.JUNET
  903. Xumerin%flab.flab.Fujitsu.JUNET@uunet.uu.NET
  904. END_OF_FILE
  905. if test 1506 -ne `wc -c <'ktest'`; then
  906.     echo shar: \"'ktest'\" unpacked with wrong size!
  907. fi
  908. # end of 'ktest'
  909. fi
  910. if test -f 'lwf.man' -a "${1}" != "-c" ; then 
  911.   echo shar: Will not clobber existing file \"'lwf.man'\"
  912. else
  913. echo shar: Extracting \"'lwf.man'\" \(7143 characters\)
  914. sed "s/^X//" >'lwf.man' <<'END_OF_FILE'
  915. X.TH LWF 1-LOCAL "21 February 1988"
  916. X.UC
  917. X.SH NAME
  918. Xlwf \- ASCII to PostScript filter
  919. X.SH SYNOPSIS
  920. X.B lwf
  921. X[-c#] [-d] [-i#] [-l] [-m] [-olist] [-p[str]]
  922. X.br
  923. X.ti +4
  924. X[-P filename] [-r] [-s#] [-S] [-t#] [-v] [file ...]
  925. X.SH DESCRIPTION
  926. X.I Lwf
  927. Xtakes one or more ASCII text files as input and produces PostScript
  928. Xinstructions that may be sent (see \fBlpr(1)\fR) to a PostScript printer
  929. X(e.g., an Apple LaserWriter) for printing.
  930. XIf no files are given on the command line, the standard input is read.
  931. XThe program correctly handles the form feed character and tabs and
  932. Xunderstands backspacing; underscores followed by backspaces
  933. Xmay be used to underline.
  934. XCourier font is used for English text.
  935. XAn external font,
  936. X.I k14.snf
  937. Xfrom the X window system, is used for
  938. XJapanese language text.
  939. XText between
  940. X.B <ESC>$B
  941. Xor
  942. X.B <ESC>$J
  943. Xor
  944. X.B $@
  945. Xand
  946. X.B <ESC>(B
  947. Xor
  948. X.B <ESC>(J
  949. Xor
  950. X.B (J
  951. Xis taken to be Japanese in the JIS code.
  952. X(I hope this covers the conventions for switching to and
  953. Xfrom Japanese in
  954. X.I kterm
  955. Xand
  956. X.IR JTeX .)
  957. X.PP
  958. XThe output conforms to the Adobe 2.0 file structuring conventions.
  959. X.PP
  960. XNote that flag arguments apply to all of the files in the argument list.
  961. XFor example, using ``-s8'' prints each of the files in 8 point type.
  962. X.PP
  963. XMultiple copies of each page can be printed by immediately following the
  964. X.B -c
  965. Xflag with the number of copies to make.
  966. XThe pages are not collated.
  967. X.PP
  968. XLines may be indented (shifted to the right) using the \fB-i\fR flag.
  969. XThis flag is immediately followed by the distance in inches to shift
  970. Xall text from the left edge of the paper instead of the default amount
  971. X(about 1/3 of an inch); the resolution is approximately 1/72 of an inch.
  972. X.PP
  973. XThe
  974. X.B -l
  975. Xflag indicates that landscape format is to be used instead of the default
  976. Xportrait format.
  977. X.PP
  978. XMargins suitable for use with a three hole punch can be obtained using the
  979. X.B -m
  980. Xflag.
  981. XThis flag may be used with either portrait or landscape mode.
  982. XIn portrait mode the
  983. X.B -m
  984. Xflag and any indentation specified by a
  985. X.B -i
  986. Xflag are additive.
  987. X.PP
  988. XThe
  989. X.B -o
  990. Xflag is immediately followed by a range specification that indicates
  991. Xwhich pages are to be printed.
  992. XA range specification is a comma-separated list of numbers and ranges.
  993. XA number N selects the Nth page;
  994. Xa range N:M selects the Nth through Mth pages, inclusive;
  995. Xan initial :N selects from the beginning up to and including the
  996. XNth page; and a final N: selects from the Nth page to the end.
  997. XThe default, ``:'', is to print all pages.
  998. X.PP
  999. XThe
  1000. X.B -p
  1001. Xflag indicates that
  1002. X.B pr(1)
  1003. Xis to be used to perform pagination and print page headers.
  1004. XAn argument string to be passed on to \fBpr(1)\fR can immediately
  1005. Xfollow the flag.
  1006. XThe usual way of producing multicolumn output is to pass a
  1007. X.B -n
  1008. Xflag to
  1009. X\fBpr(1)\fR, where
  1010. X.B n
  1011. Xis the number of columns to generate.
  1012. XNote that this string must be properly quoted if it contains whitespace,
  1013. Xmetacharacters, backslashes, etc.
  1014. X\fILwf\fR passes on the number of lines and columns to
  1015. X\fBpr(1)\fR so that multicolumn output is handled correctly.
  1016. XWhen specifying multicolumns you are responsible for selecting
  1017. Xan appropriate point size and/or landscape format.
  1018. XThe formfeed character is handled incorrectly by some versions of
  1019. X\fBpr(1)\fR when multiple columns have been specified.
  1020. XInstead of starting a new column or page it simply passes formfeeds
  1021. Xthrough.
  1022. X.B Lwf
  1023. Xfilters out these formfeeds.
  1024. X.PP
  1025. X.I Lwf
  1026. Xnormally includes a standard PostScript prologue in its output
  1027. X(usually /usr/local/lib/lwf.prologue).
  1028. XThe argument following a
  1029. X.B -P
  1030. Xflag specifies a prologue file to be substituted for the standard
  1031. Xsystem file.
  1032. X.PP
  1033. XThe default is to not perform page reversal, which is correct for printers
  1034. Xlike the NEC Silentwriter LC-890.
  1035. XThe
  1036. X.B -r
  1037. Xflag enables page reversal so that the pages appear in
  1038. Xthe correct sequence in the output tray of printers like the Apple
  1039. XLaserWriter.
  1040. X.PP
  1041. XThe
  1042. X.B -s
  1043. Xflag, immediately followed by a 7, 8, 9, 10, 11, 12, 14, 16, or 18 causes
  1044. Xthe corresponding point size to be used.
  1045. XThe default point size is 10.
  1046. X.PP
  1047. XBy default, the output of
  1048. X.I lwf
  1049. Xis intended to go through a spooler that monitors the status of the
  1050. Xprinter and separates jobs.
  1051. XThe
  1052. X.B -S
  1053. Xflag indicates that such a monitor is not being used and that a
  1054. Xheader page should be printed to separate jobs and end-of-file characters
  1055. Xshould be inserted in the output.
  1056. X.PP
  1057. XThe
  1058. X.B -t
  1059. Xflag is immediately followed by a number indicating the distance between
  1060. Xtab stops.
  1061. XThe default value is 8 characters.
  1062. X.PP
  1063. XThe
  1064. X.B -d
  1065. Xand
  1066. X.B -v
  1067. Xflags are used for debugging.
  1068. X.SH EXAMPLES
  1069. XThe command
  1070. X.sp 2
  1071. X.ti +5
  1072. Xlwf -p-2 -i0.5 -s12 file1.c file2.c | lpr -Plw
  1073. X.sp 2
  1074. Xwould print the two files on printer 'lw' in portrait format with
  1075. Xpage headings, indenting 0.5 inches from the left edge, using 12
  1076. Xpoint type.
  1077. XEach file would be printed in two columns.
  1078. X.sp 1
  1079. XThe command
  1080. X.sp 2
  1081. X.ti +5
  1082. Xlwf -l -s7 -p'-h foo' | lpr -Plw
  1083. X.sp 2
  1084. Xwould print the standard input with page headings in landscape format
  1085. Xusing 7 point type.
  1086. XThe filename for the header line would be 'foo'.
  1087. X.sp 1
  1088. XThe command
  1089. X.sp 2
  1090. X.ti +5
  1091. Xlwf -p'-h foo .login -h bar .cshrc' | lpr -Plw
  1092. X.sp 2
  1093. Xwould print the file ``.login'' with a header title ``foo'' and ``.cshrc''
  1094. Xwith the header title ``bar''.
  1095. X.sp 1
  1096. XA useful csh alias is:
  1097. X.sp 2
  1098. X.ti +5
  1099. Xalias prlw 'lwf -s7 -t4 -l -p-2 \\!* | lpr -Plw'
  1100. X.sp 2
  1101. Xwhich, when invoked as
  1102. X.sp 2
  1103. X.ti +5
  1104. Xprlw foo1 foo2
  1105. X.sp 2
  1106. Xprints foo1 and foo2, two columns per page, on printer 'lw'.
  1107. X.SH FILES
  1108. X/tmp/lwfXXXXXX        \- temporary file used for page reversal
  1109. X.br
  1110. X/usr/local/lib/k14.snf    \- Japanese font
  1111. X.SH SEE ALSO
  1112. Xpr(1), lpr(1)
  1113. X.SH LIMITATIONS
  1114. XThe maximum input line length is 1024 characters.
  1115. XThis should not present a problem since the corresponding output line
  1116. Xlength would be too long to be printed.
  1117. XThe program quits and prints a message if an input line is too long.
  1118. XOutput lines that are too long are normally silently truncated by the
  1119. Xprinter.
  1120. X.sp 2
  1121. X.I Lwf
  1122. Xcan be compiled such that there is a limit on the number of pages it can
  1123. Xproduce.
  1124. X.SH BUGS
  1125. XIt might be argued that flags should be allowed to be interspersed between
  1126. Xfile arguments.
  1127. X.sp 2
  1128. XThe character '\\001' (SOH) should not appear in the input as it is used
  1129. Xwithin the program to delimit columns.
  1130. XThe first time the program reads this character it determines the number
  1131. Xof columns being printed; all subsequent lines are expected to
  1132. Xhave this number of columns or be ``single column''.
  1133. X.sp 2
  1134. XA \fB-s\fR flag should not be passed on to \fBpr(1)\fR since
  1135. X.I lwf
  1136. Xuses it.
  1137. X.sp 2
  1138. XThe program can only handle the 9 different point sizes, the single
  1139. XLW font Courier, and the single external kanji raster font k14.
  1140. X(The data for the 14, 16, and 18 point sizes was added by GL without
  1141. Xtesting.)
  1142. XThe printing of Japanese text is slow, since the Japanese characters
  1143. Xare not loaded to the LW as a PostScript font (there are too many
  1144. Xof them to do that).
  1145. X.sp 2
  1146. XSo much for metric.
  1147. X.SH AUTHORS
  1148. XBarry Brachman
  1149. X.br
  1150. XDept. of Computer Science
  1151. X.br
  1152. XUniversity of British Columbia
  1153. X.sp
  1154. XGreg Lee, lee@uhccux.uhcc.hawaii.edu (extension to print kanji)
  1155. X.br
  1156. XDept. of Linguistics
  1157. X.br
  1158. XUniversity of Hawaii
  1159. X.sp
  1160. XCode for accessing the X font was taken from the X programs
  1161. X.I showsnf.c fontutil.c
  1162. Xwritten by Ralph Swick.
  1163. X
  1164. END_OF_FILE
  1165. if test 7143 -ne `wc -c <'lwf.man'`; then
  1166.     echo shar: \"'lwf.man'\" unpacked with wrong size!
  1167. fi
  1168. # end of 'lwf.man'
  1169. fi
  1170. if test -f 'misc.h' -a "${1}" != "-c" ; then 
  1171.   echo shar: Will not clobber existing file \"'misc.h'\"
  1172. else
  1173. echo shar: Extracting \"'misc.h'\" \(3109 characters\)
  1174. sed "s/^X//" >'misc.h' <<'END_OF_FILE'
  1175. X/***********************************************************
  1176. XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  1177. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  1178. X
  1179. X                        All Rights Reserved
  1180. X
  1181. XPermission to use, copy, modify, and distribute this software and its 
  1182. Xdocumentation for any purpose and without fee is hereby granted, 
  1183. Xprovided that the above copyright notice appear in all copies and that
  1184. Xboth that copyright notice and this permission notice appear in 
  1185. Xsupporting documentation, and that the names of Digital or MIT not be
  1186. Xused in advertising or publicity pertaining to distribution of the
  1187. Xsoftware without specific, written prior permission.  
  1188. X
  1189. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1190. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1191. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1192. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1193. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1194. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1195. XSOFTWARE.
  1196. X
  1197. X******************************************************************/
  1198. X/* $Header: misc.h,v 1.48 88/02/21 18:25:20 rws Exp $ */
  1199. X#ifndef MISC_H
  1200. X#define MISC_H 1
  1201. X/*
  1202. X *  X internal definitions 
  1203. X *
  1204. X */
  1205. X
  1206. X
  1207. Xextern unsigned long globalSerialNumber;
  1208. X
  1209. X#ifndef NULL
  1210. X#define NULL            0
  1211. X#endif
  1212. X
  1213. X#define MAXSCREENS    3
  1214. X#define MAXCLIENTS    128
  1215. X#define MAXFORMATS    8
  1216. X#define MAXVISUALS_PER_SCREEN 50
  1217. X
  1218. Xtypedef unsigned char *pointer;
  1219. Xtypedef int Bool;
  1220. Xtypedef unsigned long PIXEL;
  1221. Xtypedef unsigned long ATOM;
  1222. X
  1223. X
  1224. X#ifndef TRUE
  1225. X#define TRUE 1
  1226. X#define FALSE 0
  1227. X#endif
  1228. X#include "os.h"     /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
  1229. X
  1230. X#define NullBox ((BoxPtr)0)
  1231. X#define MILLI_PER_MIN (1000 * 60)
  1232. X#define MILLI_PER_SECOND (1000)
  1233. X
  1234. X    /* this next is used with None and ParentRelative to tell
  1235. X       PaintWin() what to use to paint the background. Also used
  1236. X       in the macro IS_VALID_PIXMAP */
  1237. X
  1238. X#define USE_BACKGROUND_PIXEL 3
  1239. X#define USE_BORDER_PIXEL 3
  1240. X
  1241. X
  1242. X/* byte swap a long literal */
  1243. X#define lswapl(x) ((((x) & 0xff) << 24) |\
  1244. X           (((x) & 0xff00) << 8) |\
  1245. X           (((x) & 0xff0000) >> 8) |\
  1246. X           (((x) >> 24) & 0xff))
  1247. X
  1248. X/* byte swap a short literal */
  1249. X#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
  1250. X
  1251. X#define min(a, b) (((a) < (b)) ? (a) : (b))
  1252. X#define max(a, b) (((a) > (b)) ? (a) : (b))
  1253. X#define abs(a) ((a) > 0 ? (a) : -(a))
  1254. X#define fabs(a) ((a) > 0.0 ? (a) : -(a))    /* floating absolute value */
  1255. X#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
  1256. X
  1257. X#define MAXSHORT 32767
  1258. X#define MINSHORT -MAXSHORT 
  1259. X
  1260. X
  1261. X/* byte swap a long */
  1262. X#define swapl(x, n) n = ((char *) (x))[0];\
  1263. X         ((char *) (x))[0] = ((char *) (x))[3];\
  1264. X         ((char *) (x))[3] = n;\
  1265. X         n = ((char *) (x))[1];\
  1266. X         ((char *) (x))[1] = ((char *) (x))[2];\
  1267. X         ((char *) (x))[2] = n;
  1268. X
  1269. X/* byte swap a short */
  1270. X#define swaps(x, n) n = ((char *) (x))[0];\
  1271. X         ((char *) (x))[0] = ((char *) (x))[1];\
  1272. X         ((char *) (x))[1] = n
  1273. X
  1274. X
  1275. X
  1276. Xtypedef struct _DDXPoint *DDXPointPtr;
  1277. Xtypedef struct _Box *BoxPtr;
  1278. X
  1279. X#endif /* MISC_H */
  1280. END_OF_FILE
  1281. if test 3109 -ne `wc -c <'misc.h'`; then
  1282.     echo shar: \"'misc.h'\" unpacked with wrong size!
  1283. fi
  1284. # end of 'misc.h'
  1285. fi
  1286. if test -f 'os.h' -a "${1}" != "-c" ; then 
  1287.   echo shar: Will not clobber existing file \"'os.h'\"
  1288. else
  1289. echo shar: Extracting \"'os.h'\" \(3138 characters\)
  1290. sed "s/^X//" >'os.h' <<'END_OF_FILE'
  1291. X/***********************************************************
  1292. XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  1293. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  1294. X
  1295. X                        All Rights Reserved
  1296. X
  1297. XPermission to use, copy, modify, and distribute this software and its 
  1298. Xdocumentation for any purpose and without fee is hereby granted, 
  1299. Xprovided that the above copyright notice appear in all copies and that
  1300. Xboth that copyright notice and this permission notice appear in 
  1301. Xsupporting documentation, and that the names of Digital or MIT not be
  1302. Xused in advertising or publicity pertaining to distribution of the
  1303. Xsoftware without specific, written prior permission.  
  1304. X
  1305. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1306. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1307. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1308. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1309. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1310. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1311. XSOFTWARE.
  1312. X
  1313. X******************************************************************/
  1314. X
  1315. X/* $Header: os.h,v 1.23 88/01/04 08:34:02 rws Exp $ */
  1316. X
  1317. X#ifndef OS_H
  1318. X#define OS_H
  1319. X#include "misc.h"
  1320. X
  1321. X#define NullFID ((FID) 0)
  1322. X
  1323. X#define SCREEN_SAVER_ON   0
  1324. X#define SCREEN_SAVER_OFF  1
  1325. X#define SCREEN_SAVER_FORCER 2
  1326. X
  1327. X#define MAX_REQUEST_SIZE 16384
  1328. X
  1329. Xtypedef pointer    FID;
  1330. Xtypedef struct _FontPathRec *FontPathPtr;
  1331. Xtypedef struct _NewClientRec *NewClientPtr;
  1332. X
  1333. X/*
  1334. X * os-dependent definition of local allocation and deallocation
  1335. X * If you need something other than malloc/free for ALLOCATE/DEALLOCATE
  1336. X * LOCAL then you add that to the beginning of this set.  Note that
  1337. X * some machines do not return a valid pointer for malloc(0), in
  1338. X * which case we provide an alternate under the control of the
  1339. X * define MALLOC_0_RETURNS_NULL.  This is necessary because some
  1340. X * server code expects malloc(0) to return a valid pointer to storage.
  1341. X */
  1342. X#if defined(ibm032) && !defined(_pcc_)
  1343. X
  1344. Xchar *alloca();
  1345. X
  1346. X#define ALLOCATE_LOCAL(size) alloca((int)(size))
  1347. X#define DEALLOCATE_LOCAL(ptr)
  1348. Xpragma on(alloca);
  1349. X
  1350. X#else /* everyone else */
  1351. X
  1352. Xchar *malloc();
  1353. X
  1354. X# ifdef MALLOC_0_RETURNS_NULL
  1355. X# define ALLOCATE_LOCAL(size) malloc((unsigned)((size) > 0 ? (size) : 1))
  1356. X# else
  1357. X# define ALLOCATE_LOCAL(size) malloc((unsigned)(size))
  1358. X# endif
  1359. X
  1360. X#define DEALLOCATE_LOCAL(ptr) free((char *)(ptr))
  1361. X
  1362. X#endif
  1363. X
  1364. X#define xalloc(size) Xalloc((unsigned long)(size))
  1365. X#define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size))
  1366. X#define xfree(ptr) Xfree((pointer)(ptr))
  1367. X
  1368. Xchar *ReadRequestFromClient();   /* should be xReq but then include Xproto.h */
  1369. XBool CloseDownConnection();
  1370. Xvoid CreateWellKnownSockets();
  1371. Xvoid SetDefaultFontPath();
  1372. Xvoid FreeFontRecord();
  1373. Xvoid SetFontPath();
  1374. XFontPathPtr GetFontPath();
  1375. XFontPathPtr ExpandFontNamePattern();
  1376. XFID FiOpenForRead();
  1377. Xvoid AbortServer();
  1378. Xvoid ErrorF();
  1379. Xunsigned long *Xalloc();
  1380. Xunsigned long *Xrealloc();
  1381. Xvoid Xfree();
  1382. X
  1383. Xchar *strcat();
  1384. Xchar *strncat();
  1385. Xchar *strcpy();
  1386. Xchar *strncpy();
  1387. X
  1388. X#endif /* OS_H */
  1389. END_OF_FILE
  1390. if test 3138 -ne `wc -c <'os.h'`; then
  1391.     echo shar: \"'os.h'\" unpacked with wrong size!
  1392. fi
  1393. # end of 'os.h'
  1394. fi
  1395. if test -f 'range.c' -a "${1}" != "-c" ; then 
  1396.   echo shar: Will not clobber existing file \"'range.c'\"
  1397. else
  1398. echo shar: Extracting \"'range.c'\" \(7832 characters\)
  1399. sed "s/^X//" >'range.c' <<'END_OF_FILE'
  1400. X/* vi: set tabstop=4 : */
  1401. X
  1402. X/*
  1403. X * Return 1 if the given number is in the specified range,
  1404. X * -1 if there is an error in the range specification,
  1405. X * 0 otherwise
  1406. X *
  1407. X * Ranges have a similar (we use a colon instead of a dash) form to that
  1408. X * used by [nt]roff; i.e., a comma separated list of specifiers of the
  1409. X * form:
  1410. X *    1) n    means     x such that x = n
  1411. X *    2) :n    means all x such that x <= n
  1412. X *    3) n:    means all x such that x >= n
  1413. X *    4) n:m    means all x such that n <= x <= m
  1414. X *    5) :    means all x
  1415. X * n is an int
  1416. X *
  1417. X * Problems:
  1418. X * The routine prints an error message if the range is strange - this
  1419. X * might not always be desirable.
  1420. X *
  1421. X * Jul/86 BJB
  1422. X */
  1423. X
  1424. X/*
  1425. X * ===================================================================
  1426. X *
  1427. X * Permission is given to freely copy and distribute this software
  1428. X * providing:
  1429. X *
  1430. X *    1) You do not sell it,
  1431. X *    2) You do not use it for commercial advantage, and
  1432. X *    3) This notice accompanies the distribution
  1433. X *
  1434. X * Copyright (c) 1988
  1435. X * Barry Brachman
  1436. X * Dept. of Computer Science
  1437. X * Univ. of British Columbia
  1438. X * Vancouver, B.C. V6T 1W5
  1439. X *
  1440. X * .. {ihnp4!alberta, uw-beaver, uunet}!ubc-vision!ubc-csgrads!brachman
  1441. X * brachman@grads.cs.ubc.cdn
  1442. X * brachman%ubc.csnet@csnet-relay.arpa
  1443. X * brachman@ubc.csnet
  1444. X * ====================================================================
  1445. X */
  1446. X
  1447. X#include <ctype.h>
  1448. X#include <stdio.h>
  1449. X
  1450. X#define streq(a, b)            (!strcmp((a), (b)))
  1451. X#define smalloc(a, t, s)    ((a = (t) malloc((unsigned) (s))) == NULL)
  1452. X#define srealloc(a, t, b, s) ((a = (t) realloc(b, (unsigned) (s))) == NULL)
  1453. X#define max(a, b)            ((a) >= (b) ? (a) : (b))
  1454. X
  1455. X#define SEP_CHAR    ':'
  1456. X#define SEP_T        0        /* separator token */
  1457. X#define NUM_T        1        /* number token */
  1458. X#define BAD_T        2        /* token for bad character */
  1459. X
  1460. X#define STR_ALLOC    80
  1461. X
  1462. Xstruct range_header {
  1463. X    char *range_str;        /* range character string */
  1464. X    int range_str_alloc;    /* length in bytes */
  1465. X    int nranges;            /* number of range entries */
  1466. X    struct range *range;
  1467. X} range_header = {
  1468. X    NULL, 0, NULL
  1469. X};
  1470. X
  1471. X/*
  1472. X * If hflag (lflag) is non-zero then the high (low) value is present
  1473. X */
  1474. Xstruct range {
  1475. X    char hflag;            /* high value present */
  1476. X    char lflag;            /* low value present */
  1477. X    int high;            /* high part of range */
  1478. X    int low;            /* low part of range */
  1479. X};
  1480. X
  1481. X#ifdef RANGE_DEBUG
  1482. X
  1483. X/*
  1484. X * This is a program for demonstrating and debugging the range checking
  1485. X * code
  1486. X * Enter a range when prompted
  1487. X * (If there is a previous range shown you may enter <return> to
  1488. X * reselect it)
  1489. X * Enter a value
  1490. X * The program will indicate whether the value is in the given range
  1491. X */
  1492. X
  1493. Xchar buf[BUFSIZ], range[BUFSIZ];
  1494. X
  1495. Xmain(argc, argv)
  1496. Xint argc;
  1497. Xchar **argv;
  1498. X{
  1499. X    register int i;
  1500. X    char *p;
  1501. X    struct range_header *rh;
  1502. X    struct range *r;
  1503. X    FILE *fp;
  1504. X    char *gets(), *index(), *strcpy();
  1505. X
  1506. X    buf[0] = range[0] = '\0';
  1507. X    if (argc == 2) {
  1508. X        if ((fp = fopen(argv[1], "r")) == NULL) {
  1509. X            (void) fprintf(stderr, "Can't open %s\n", argv[1]);
  1510. X            exit(1);
  1511. X            /*NOTREACHED*/
  1512. X        }
  1513. X    }
  1514. X    else
  1515. X        fp = stdin;
  1516. X
  1517. X    if (fp == stdin)
  1518. X        (void) printf("Range? ");
  1519. X    while (fgets(buf, sizeof(buf), fp) != NULL) {
  1520. X        if ((p = index(buf, '\n')) != NULL)
  1521. X            *p = '\0';
  1522. X        if (buf[0] != '\0') {
  1523. X            (void) strcpy(range, buf);
  1524. X            if (checkrange(range)) {
  1525. X                if (fp == stdin)
  1526. X                    (void) printf("Range? ");
  1527. X                continue;
  1528. X            }
  1529. X            rh = &range_header;
  1530. X            (void) printf("%s (%d alloc) (%d ranges):\n",
  1531. X                  rh->range_str, rh->range_str_alloc, rh->nranges);
  1532. X            for (r = rh->range, i = 0; i < rh->nranges; i++, r++)
  1533. X                (void) printf("hflag=%d lflag=%d high=%d low=%d\n",
  1534. X                    r->hflag, r->lflag, r->high, r->low);
  1535. X        }
  1536. X        if (fp != stdin)
  1537. X            continue;
  1538. X        (void) printf("Value? ");
  1539. X        if (gets(buf) == NULL)
  1540. X            break;
  1541. X        i = inrange(atoi(buf), range);
  1542. X        if (i == 0)
  1543. X            (void) printf("\tno\n");
  1544. X        else if (i == 1)
  1545. X            (void) printf("\tyes\n");
  1546. X        else if (i == -1)
  1547. X            (void) printf("\terror\n");
  1548. X        else
  1549. X            (void) printf("\tbad result\n");
  1550. X        (void) printf("Range ['%s']? ", range);
  1551. X    }
  1552. X    (void) printf("\n");
  1553. X}
  1554. X#endif RANGE_DEBUG
  1555. X
  1556. X/*
  1557. X * Check and compile the given range specification and then determine if
  1558. X * the number is in the range
  1559. X * Return -1 if there is a compilation error, 1 if the number is in the
  1560. X * range, or 0 if the number isn't in the range
  1561. X */
  1562. Xinrange(num, range_spec)
  1563. Xint num;
  1564. Xchar *range_spec;
  1565. X{
  1566. X    register int i, rc;
  1567. X    register struct range_header *rh;
  1568. X    register struct range *r;
  1569. X
  1570. X    if (checkrange(range_spec))
  1571. X        return(-1);
  1572. X    rh = &range_header;
  1573. X    rc = 0;
  1574. X    for (r = rh->range, i = 0; rc == 0 && i < rh->nranges; i++, r++) {
  1575. X        if (r->hflag) {
  1576. X            if (num > r->high)
  1577. X                continue;
  1578. X            if (r->lflag && num < r->low)
  1579. X                continue;
  1580. X            rc = 1;
  1581. X        }
  1582. X        else if (r->lflag) {
  1583. X            if (num >= r->low)
  1584. X                rc = 1;
  1585. X        }
  1586. X        else                /* both unset -> ":" */
  1587. X            rc = 1;
  1588. X    }
  1589. X    return(rc);
  1590. X}
  1591. X
  1592. X/*
  1593. X * Check and compile a range specification
  1594. X * Print a message and return -1 on error; return 0 oth.
  1595. X *
  1596. X * Could be more efficient by allocating more structures at a time... SMOP
  1597. X */
  1598. Xcheckrange(range_spec)
  1599. Xchar *range_spec;
  1600. X{
  1601. X    register struct range_header *rh;
  1602. X    register struct range *r;
  1603. X    int len;
  1604. X    int ltype, lval, rtype, rval;
  1605. X    char *p;
  1606. X    char *malloc(), *realloc(), *strcpy();
  1607. X
  1608. X    rh = &range_header;
  1609. X    /*
  1610. X     * Check if the previous range is being used
  1611. X     */
  1612. X    if (rh->range_str != NULL && streq(range_spec, rh->range_str))
  1613. X        return(0);
  1614. X
  1615. X    /*
  1616. X     * New range spec
  1617. X     * If there is enough space, reuse it; oth. allocate enough
  1618. X     * (amount allocated never shrinks)
  1619. X     */
  1620. X    len = max(strlen(range_spec) + 1, STR_ALLOC);
  1621. X    if (rh->range_str != NULL  && len > rh->range_str_alloc) {
  1622. X        free(rh->range_str);
  1623. X        rh->range_str = (char *) malloc((unsigned) len);
  1624. X        rh->range_str_alloc = len;
  1625. X    }
  1626. X    else if (rh->range_str == NULL) {
  1627. X        rh->range_str = (char *) malloc((unsigned) len);
  1628. X        rh->range_str_alloc = len;
  1629. X    }
  1630. X    (void) strcpy(rh->range_str, range_spec);
  1631. X    if (rh->range != NULL)
  1632. X        free((char *) rh->range);
  1633. X    rh->range = NULL;
  1634. X
  1635. X    p = range_spec;
  1636. X    while (1) {
  1637. X        lval = getnum(&p, <ype);
  1638. X        if (ltype == BAD_T) {
  1639. X            (void) fprintf(stderr, "range: bad first number\n");
  1640. X            *rh->range_str = '\0';        /* invalidate */
  1641. X            return(-1);
  1642. X        }
  1643. X
  1644. X        if (rh->range == NULL) {
  1645. X            smalloc(r, struct range *, sizeof(struct range));
  1646. X            rh->nranges = 1;
  1647. X        }
  1648. X        else {
  1649. X            len = sizeof(struct range) * ++(rh->nranges);
  1650. X            srealloc(r, struct range *, (char *) rh->range, len);
  1651. X        }
  1652. X        rh->range = r;
  1653. X        r += rh->nranges - 1;        /* point to new one */
  1654. X        r->hflag = r->lflag = 0;
  1655. X        r->high = r->low = 0;
  1656. X
  1657. X        /*
  1658. X         * If ltype != NUM_T there is no lval
  1659. X         */
  1660. X        if (ltype == NUM_T) {
  1661. X            r->lflag = 1;
  1662. X            r->low = lval;
  1663. X        }
  1664. X
  1665. X        switch (*p) {
  1666. X        case ',':            /* single number */
  1667. X            r->hflag = 1;
  1668. X            r->high = lval;
  1669. X            p++;
  1670. X            continue;
  1671. X
  1672. X        case '\0':            /* single number at end */
  1673. X            r->hflag = 1;
  1674. X            r->high = lval;
  1675. X            return(0);
  1676. X
  1677. X        case ':':
  1678. X            p++;
  1679. X            if (*p == '\0')        /* no rval */
  1680. X                return(0);
  1681. X            if (*p == ',') {    /* no rval */
  1682. X                p++;
  1683. X                break;
  1684. X            }
  1685. X
  1686. X            rval = getnum(&p, &rtype);
  1687. X            if (rtype == BAD_T) {
  1688. X                (void) fprintf(stderr, "range: bad second number\n");
  1689. X                *rh->range_str = '\0';
  1690. X                return(-1);
  1691. X            }
  1692. X
  1693. X            if (lval > rval) {
  1694. X                (void) fprintf(stderr, "range: values reversed\n");
  1695. X                *rh->range_str = '\0';    /* invalidate */
  1696. X                return(-1);
  1697. X            }
  1698. X            r->hflag = 1;
  1699. X            r->high = rval;
  1700. X            if (*p == '\0')
  1701. X                return(0);
  1702. X            if (*p == ',')
  1703. X                p++;
  1704. X            break;
  1705. X
  1706. X        default:
  1707. X            (void) fprintf(stderr, "range: bad character\n");
  1708. X            *rh->range_str = '\0';        /* invalidate */
  1709. X            return(-1);
  1710. X        }
  1711. X    }
  1712. X}
  1713. X
  1714. Xstatic
  1715. Xgetnum(pp, type)
  1716. Xchar **pp;
  1717. Xint *type;
  1718. X{
  1719. X    register int sign, val;
  1720. X    register char *p;
  1721. X
  1722. X    p = *pp;
  1723. X    if (!isdigit(*p) && *p != '-') {
  1724. X        if (*p == SEP_CHAR)
  1725. X            *type = SEP_T;
  1726. X        else
  1727. X            *type = BAD_T;
  1728. X        return(0);
  1729. X    }
  1730. X    sign = 1;
  1731. X    if (*p == '-') {
  1732. X        sign = -1;
  1733. X        p++;
  1734. X    }
  1735. X    if (!isdigit(*p)) {
  1736. X        *type = BAD_T;
  1737. X        return(0);
  1738. X    }
  1739. X    for (val = 0; isdigit(*p) && *p != '\0'; p++)
  1740. X        val = val * 10 + *p - '0';
  1741. X    if (*p != '\0' && *p != ',' && *p != SEP_CHAR) {
  1742. X        *type = BAD_T;
  1743. X        return(0);
  1744. X    }
  1745. X    *pp = p;
  1746. X    *type = NUM_T;
  1747. X    return(sign * val);
  1748. X}
  1749. X
  1750. END_OF_FILE
  1751. if test 7832 -ne `wc -c <'range.c'`; then
  1752.     echo shar: \"'range.c'\" unpacked with wrong size!
  1753. fi
  1754. # end of 'range.c'
  1755. fi
  1756. if test -f 'servermd.h' -a "${1}" != "-c" ; then 
  1757.   echo shar: Will not clobber existing file \"'servermd.h'\"
  1758. else
  1759. echo shar: Extracting \"'servermd.h'\" \(5985 characters\)
  1760. sed "s/^X//" >'servermd.h' <<'END_OF_FILE'
  1761. X/***********************************************************
  1762. XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  1763. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  1764. X
  1765. X                        All Rights Reserved
  1766. X
  1767. XPermission to use, copy, modify, and distribute this software and its 
  1768. Xdocumentation for any purpose and without fee is hereby granted, 
  1769. Xprovided that the above copyright notice appear in all copies and that
  1770. Xboth that copyright notice and this permission notice appear in 
  1771. Xsupporting documentation, and that the names of Digital or MIT not be
  1772. Xused in advertising or publicity pertaining to distribution of the
  1773. Xsoftware without specific, written prior permission.  
  1774. X
  1775. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1776. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1777. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1778. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1779. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1780. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1781. XSOFTWARE.
  1782. X
  1783. X******************************************************************/
  1784. X#ifndef SERVERMD_H
  1785. X#define SERVERMD_H 1
  1786. X/* $Header: servermd.h,v 1.30 88/05/17 13:41:01 rws Exp $ */
  1787. X
  1788. X/*
  1789. X * The vendor string identifies the vendor responsible for the
  1790. X * server executable.
  1791. X */
  1792. X#ifndef VENDOR_STRING
  1793. X#define VENDOR_STRING "MIT X Consortium"
  1794. X#endif    VENDOR_STRING
  1795. X
  1796. X/*
  1797. X * The vendor release number identifies, for the purpose of submitting
  1798. X * traceable bug reports, the release number of software produced
  1799. X * by the vendor.
  1800. X */
  1801. X#ifndef VENDOR_RELEASE
  1802. X#define VENDOR_RELEASE    2
  1803. X#endif    VENDOR_RELEASE
  1804. X
  1805. X/*
  1806. X * Machine dependent values:
  1807. X * GLYPHPADBYTES should be chosen with consideration for the space-time
  1808. X * trade-off.  Padding to 0 bytes means that there is no wasted space
  1809. X * in the font bitmaps (both on disk and in memory), but that access of
  1810. X * the bitmaps will cause odd-address memory references.  Padding to
  1811. X * 2 bytes would ensure even address memory references and would
  1812. X * be suitable for a 68010-class machine, but at the expense of wasted
  1813. X * space in the font bitmaps.  Padding to 4 bytes would be good
  1814. X * for real 32 bit machines, etc.  Be sure that you tell the font
  1815. X * compiler what kind of padding you want because its defines are
  1816. X * kept separate from this.  See server/include/fonts.h for how
  1817. X * GLYPHPADBYTES is used.
  1818. X *
  1819. X * Along with this, you should choose an appropriate value for
  1820. X * GETLEFTBITS_ALIGNMENT, which is used in ddx/mfb/maskbits.h.  This
  1821. X * constant choses what kind of memory references are guarenteed during
  1822. X * font access; either 1, 2 or 4, for byte, word or longword access,
  1823. X * respectively.  For instance, if you have decided to to have
  1824. X * GLYPHPADBYTES == 4, then it is pointless for you to have a
  1825. X * GETLEFTBITS_ALIGNMENT > 1, because the padding of the fonts has already
  1826. X * guarenteed you that your fonts are longword aligned.  On the other
  1827. X * hand, even if you have chosen GLYPHPADBYTES == 1 to save space, you may
  1828. X * also decide that the computing involved in aligning the pointer is more
  1829. X * costly than an odd-address access; you choose GETLEFTBITS_ALIGNMENT == 1.
  1830. X * 
  1831. X * XXX: this code has changed since beta test and only GLYPHPADBYTES == 4
  1832. X * has been tested, hence all machines have this same value.
  1833. X *
  1834. X */
  1835. X
  1836. X#ifdef vax
  1837. X
  1838. X#define IMAGE_BYTE_ORDER    LSBFirst        /* Values for the VAX only */
  1839. X#define BITMAP_BIT_ORDER    LSBFirst
  1840. X#define    GLYPHPADBYTES        1
  1841. X#define GETLEFTBITS_ALIGNMENT    4
  1842. X
  1843. X#else
  1844. X# ifdef sun
  1845. X
  1846. X# if (sun386 || sun5)
  1847. X#define IMAGE_BYTE_ORDER    LSBFirst        /* Values for the SUN only */
  1848. X#define BITMAP_BIT_ORDER    LSBFirst
  1849. X# else
  1850. X#define IMAGE_BYTE_ORDER    MSBFirst        /* Values for the SUN only */
  1851. X#define BITMAP_BIT_ORDER    MSBFirst
  1852. X# endif
  1853. X
  1854. X#define    GLYPHPADBYTES        4
  1855. X#define GETLEFTBITS_ALIGNMENT    4
  1856. X
  1857. X# else
  1858. X#  ifdef apollo
  1859. X
  1860. X#define IMAGE_BYTE_ORDER    MSBFirst        /* Values for the Apollo only*/
  1861. X#define BITMAP_BIT_ORDER    MSBFirst
  1862. X#define    GLYPHPADBYTES        2
  1863. X#define GETLEFTBITS_ALIGNMENT    4
  1864. X
  1865. X#  else
  1866. X#   ifdef ibm032
  1867. X
  1868. X#define IMAGE_BYTE_ORDER    MSBFirst        /* Values for the RT only*/
  1869. X#define BITMAP_BIT_ORDER    MSBFirst
  1870. X#define    GLYPHPADBYTES        1
  1871. X#define GETLEFTBITS_ALIGNMENT    4
  1872. X/* ibm pcc doesn't understand pragmas. */
  1873. X
  1874. X#   else
  1875. X#    ifdef hpux
  1876. X
  1877. X#define IMAGE_BYTE_ORDER    MSBFirst        /* Values for the HP only */
  1878. X#define BITMAP_BIT_ORDER    MSBFirst
  1879. X#define    GLYPHPADBYTES        2
  1880. X#define    GETLEFTBITS_ALIGNMENT    4
  1881. X
  1882. X#    endif
  1883. X
  1884. X#   endif
  1885. X#  endif
  1886. X# endif
  1887. X#endif
  1888. X
  1889. X/* size of buffer to use with GetImage, measured in bytes. There's obviously
  1890. X * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
  1891. X * you) used and the number of times the ddx routine has to be called.
  1892. X * 
  1893. X * for a 1024 x 864 bit monochrome screen  with a 32 bit word we get 
  1894. X * 8192/4 words per buffer 
  1895. X * (1024/32) = 32 words per scanline
  1896. X * 2048 words per buffer / 32 words per scanline = 64 scanlines per buffer
  1897. X * 864 scanlines / 64 scanlines = 14 buffers to draw a full screen
  1898. X */
  1899. X#define IMAGE_BUFSIZE        8192
  1900. X
  1901. X/* pad scanline to a longword */
  1902. X#define BITMAP_SCANLINE_UNIT    32
  1903. X#define BITMAP_SCANLINE_PAD  32
  1904. X
  1905. X#define LOG2_BITMAP_PAD        5
  1906. X#define LOG2_BYTES_PER_SCANLINE_PAD    2
  1907. X
  1908. X/* 
  1909. X *   This returns the number of padding units, for depth d and width w.
  1910. X * For bitmaps this can be calculated with the macros above.
  1911. X * Other depths require either grovelling over the formats field of the
  1912. X * screenInfo or hardwired constants.
  1913. X */
  1914. X
  1915. Xtypedef struct _PaddingInfo {
  1916. X    int    scanlinePad;
  1917. X    int    bitmapPadLog2;
  1918. X} PaddingInfo;
  1919. Xextern PaddingInfo PixmapWidthPaddingInfo[];
  1920. X
  1921. X#define PixmapWidthInPadUnits(w, d) \
  1922. X    (((w) + PixmapWidthPaddingInfo[d].scanlinePad) >> \
  1923. X    PixmapWidthPaddingInfo[d].bitmapPadLog2)
  1924. X
  1925. X/*
  1926. X *    Return the number of bytes to which a scanline of the given
  1927. X * depth and width will be padded.
  1928. X */
  1929. X#define PixmapBytePad(w, d) \
  1930. X    (PixmapWidthInPadUnits(w, d) << LOG2_BYTES_PER_SCANLINE_PAD)
  1931. X
  1932. X#endif SERVERMD_H
  1933. END_OF_FILE
  1934. if test 5985 -ne `wc -c <'servermd.h'`; then
  1935.     echo shar: \"'servermd.h'\" unpacked with wrong size!
  1936. fi
  1937. # end of 'servermd.h'
  1938. fi
  1939. echo shar: End of archive 1 \(of 3\).
  1940. cp /dev/null ark1isdone
  1941. MISSING=""
  1942. for I in 1 2 3 ; do
  1943.     if test ! -f ark${I}isdone ; then
  1944.     MISSING="${MISSING} ${I}"
  1945.     fi
  1946. done
  1947. if test "${MISSING}" = "" ; then
  1948.     echo You have unpacked all 3 archives.
  1949.     rm -f ark[1-9]isdone
  1950. else
  1951.     echo You still need to unpack the following archives:
  1952.     echo "        " ${MISSING}
  1953. fi
  1954. ##  End of shell archive.
  1955. exit 0
  1956.  
  1957. -- 
  1958.          -- Greg, lee@uhccux.uhcc.hawaii.edu
  1959.